//
//  RectContainPoint.m
//  emotions
//
//  Created by wd on 15/7/6.
//  Copyright (c) 2015年 wcl. All rights reserved.
//

#import "RectContainPoint.h"

@implementation RectContainPoint

+ (BOOL)rectContainsPoint:(CGRect)rect point:(CGPoint)point;
{
    //左上角
    CGPoint point_lt = rect.origin;
    //左下角
    CGPoint point_lb = CGPointMake(point_lt.x, point_lt.y + CGRectGetHeight(rect));
    //右上角
    CGPoint point_rt = CGPointMake(point_lt.x + CGRectGetWidth(rect), point_lt.y);
    //右下角
    CGPoint point_rb = CGPointMake(point_lt.x + CGRectGetWidth(rect), point_lt.y + CGRectGetHeight(rect));
    
    CGMutablePathRef pathRef=CGPathCreateMutable();
    CGPathMoveToPoint(pathRef, NULL, point_lt.x, point_lt.y);
    CGPathAddLineToPoint(pathRef, NULL, point_rt.x, point_rt.y);
    CGPathAddLineToPoint(pathRef, NULL, point_rb.x, point_rb.y);
    CGPathAddLineToPoint(pathRef, NULL, point_lb.x, point_lb.y);
    CGPathAddLineToPoint(pathRef, NULL, point_lt.x, point_lt.y);
    CGPathCloseSubpath(pathRef);
//    CGPathRelease(pathRef);
    return CGPathContainsPoint(pathRef, NULL, point, NO);
}

@end
